/*
 * Copyright 2006-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.martinimix.domain.account;

import java.io.Serializable;
import java.util.Calendar;


/**
 * Provides a customer bean.
 * 
 * @author Scott Rossillo
 *
 */
public class Customer implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	/**
	 * @@BusinessObjectProperty("usa_id")
	 */
	private Long id;
	
	/**
	 * @@BusinessObjectProperty("customerNum")
	 */
	private String number;
	
	/**
	 * @@BusinessObjectProperty("userRandomNum")
	 */
	private Double randomNumber;
	
	/**
	 * @@BusinessObjectProperty("email")
	 */
	private String emailAddress;
	
	/**
	 *  @@BusinessObjectProperty("optOut")
	 */
	private boolean optIn;
	
	/**
	 * @@BusinessObjectProperty("userid")
	 */
	private String username;
	private String password;
	private boolean passwordExpired;
	
	private Calendar passwordChangeDate;
	
	private String firstName;
	private String lastName;
	
	/**
	 * @@BusinessObjectProperty("status_cd")
	 */
	private String statusCode;
	private int loginCount;

	/**
	 * @@BusinessObjectProperty("type_cd")
	 */
	private String typeCode;	
	
	/**
	 * @@BusinessObjectProperty("usa_bill_to_uad_id")
	 */
	private Long defaultBillingAddressId;
	
	/**
	 * @@BusinessObjectProperty("usa_ship_to_uad_id")
	 */
	private Long defaultShippingAddressId;
	
	/**
	 * @@BusinessObjectProperty("usa_default_ccd_id")
	 */
	private Long defaultCreditCardId;
	
	private long createdBy;
	private long modifiedBy;
	
	/**
	 * @@BusinessObjectProperty("createDt")
	 */
	private Calendar createdDate;
	
	/**
	 * @@BusinessObjectProperty("modifyDt")
	 */
	private Calendar modifiedDate;
	
	/**
	 * Creates a new customer.
	 */
	public Customer() {
		optIn = true;
	}
	
	/**
	 * Creates a copy of the given customer.
	 * 
	 * @param customer the <code>Customer</code> whose fields will be
	 * copied to this new <code>Customer</code>
	 */
	protected Customer(Customer customer) {
		
		if(customer == null) {
			throw new IllegalArgumentException("Customer cannot be null");
		}
		
		this.id = customer.id;
		this.username = customer.username;
		this.emailAddress = customer.emailAddress;
		
		this.firstName = customer.firstName;
		this.lastName = customer.lastName;
		
		this.number = customer.number;
		this.randomNumber = customer.randomNumber;
		this.optIn = customer.optIn;
		
		this.loginCount = customer.loginCount;
		this.password = customer.password;
		this.passwordExpired = customer.passwordExpired;
		
		this.statusCode = customer.statusCode;
		this.typeCode = customer.typeCode;

		this.createdBy = customer.createdBy;
		this.modifiedBy = customer.modifiedBy;
	}
	
	/**
	 * Returns the unique identifier for this customer.
	 * 
	 * @return the id for this customer
	 */
	public Long getId() {
		return id;
	}
	
	/**
	 * Sets this customer's unique identifier.
	 * 
	 * @param id the unique identifier for this customer
	 */
	public void setId(Long id) {
		this.id = id;
	}
	
	/**
	 * Returns this customer's email address.
	 * 
	 * @return this customer's email address
	 */
	public String getEmailAddress() {
		return emailAddress;
	}
	
	/**
	 * Sets this customer's email address
	 * 
	 * @param emailAddress the email address for this customer
	 */
	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}
	
	/**
	 * Returns true if this customer is opted in for promotional 
	 * offers.
	 * 
	 * @return <code>true</code> if this customer is opted in
	 * for promotional offers; <code>false</code> otherwise 
	 */
	public boolean isOptIn() {
		return optIn;
	}
	
	/**
	 * Sets whether or not this customer is opt-in for promotions.
	 * 
	 * @param optIn <code>true</code> if this customer is opted in
	 * for promotional offers; <code>false</code> otherwise 
	 */
	public void setOptIn(boolean optIn) {
		this.optIn = optIn;
	}
	
	/**
	 * Returns this customers user name.
	 * 
	 * @return the user name for this customer
	 */
	public String getUsername() {
		return username;
	}
	
	/**
	 * Sets the user name for this customer.
	 * 
	 * @param username the user name for this customer 
	 */
	public void setUsername(String username) {
		this.username = username;
	}
	
	/**
	 * Returns this customer's password.
	 * 
	 * @return the password for this customer
	 */
	public String getPassword() {
		return password;
	}
	
	/**
	 * Sets the password for this customer.
	 * 
	 * @param password the password for this customer
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	
	public String getFirstName() {
		return firstName;
	}
	
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	
	public String getLastName() {
		return lastName;
	}
	
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	/**
	 * Returns the unique number for this customer.
	 * 
	 * @return a unique number identifying this customer.
	 */
	public String getNumber() {
		return number;
	}
	
	/**
	 * Sets the unique number identifying this customer.
	 * 
	 * @param number this customer's number
	 */
	public void setNumber(String number) {
		this.number = number;
	}
	
	/**
	 * Returns true if this customer's password has expired.
	 * 
	 * @return <code>true</code> if this customer's password has expired;
	 * <code>false</code> otherwise
	 */
	public boolean isPasswordExpired() {
		return passwordExpired;
	}
	
	/**
	 * Returns true if this customer is a registered user.
	 * 
	 * @return <code>true</code> if this customer is registered;
	 * <code>false</code> otherwise
	 */
	public boolean isRegistered() {
		return this.getUsername() != null;
	}
	
	public void setPasswordExpired(boolean passwordExpired) {
		this.passwordExpired = passwordExpired;
	}
	
	public Long getDefaultBillingAddressId() {
		return defaultBillingAddressId;
	}

	public void setDefaultBillingAddressId(Long defaultBillingAddressId) {
		this.defaultBillingAddressId = defaultBillingAddressId;
	}

	public Long getDefaultShippingAddressId() {
		return defaultShippingAddressId;
	}

	public void setDefaultShippingAddressId(Long defaultShippingAddressId) {
		this.defaultShippingAddressId = defaultShippingAddressId;
	}

	public Long getDefaultCreditCardId() {
		return defaultCreditCardId;
	}

	public void setDefaultCreditCardId(Long defaultCreditCardId) {
		this.defaultCreditCardId = defaultCreditCardId;
	}

	/**
	 * Returns the status code for this customer.
	 * 
	 * @return this customer's status code
	 */
	public String getStatusCode() {
		return statusCode;
	}
	
	public void setStatusCode(String statusCode) {
		this.statusCode = statusCode;
	}
	
	/**
	 * Returns the number of times this customer has logged in.
	 * 
	 * @return an <code>int</code> indicating the number of times
	 * this customer has logged in
	 */
	public int getLoginCount() {
		return loginCount;
	}
	
	/**
	 * Sets the login count for this customer.
	 * 
	 * @param loginCount the number of times this customer has logged in
	 */
	public void setLoginCount(int loginCount) {
		this.loginCount = loginCount;
	}
	
	/**
	 * Returns this customer's type.
	 * 
	 * @return this customer's type code
	 */
	public String getTypeCode() {
		return typeCode;
	}
	
	public void setTypeCode(String typeCode) {
		this.typeCode = typeCode;
	}
	
	/**
	 * Returns the identifier for the user who created 
	 * this customer
	 * 
	 * @return the id of the user who created this customer
	 */
	public long getCreatedBy() {
		return createdBy;
	}
	public void setCreatedBy(long createdBy) {
		this.createdBy = createdBy;
	}
	public long getModifiedBy() {
		return modifiedBy;
	}
	public void setModifiedBy(long modifiedBy) {
		this.modifiedBy = modifiedBy;
	}

	public Double getRandomNumber() {
		return randomNumber;
	}

	public void setRandomNumber(Double randomNumber) {
		this.randomNumber = randomNumber;
	}

	public Calendar getPasswordChangeDate() {
		return passwordChangeDate;
	}

	public void setPasswordChangeDate(Calendar passwordChangeDate) {
		this.passwordChangeDate = passwordChangeDate;
	}

	public Calendar getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Calendar createdDate) {
		this.createdDate = createdDate;
	}

	public Calendar getModifiedDate() {
		return modifiedDate;
	}

	public void setModifiedDate(Calendar modifiedDate) {
		this.modifiedDate = modifiedDate;
	}
	
}
